/*
 * pipe_upper2lower.c
 *
 *  Created on: 2012-5-3
 *      Author: jawinton
 */

#include "../apue.h"
#include <sys/wait.h>

int main (void) {
	char line[MAXLINE];
	FILE *fpin;

	if ((fpin = popen("./myuclc", "r")) == NULL) err_sys("error popen");
	while (fgets(line, MAXLINE, fpin) != NULL) {
		fputs("prompt>",stdout);
		fflush(stdout);
		if (fputs(line, stdout) == EOF) err_sys("fputs error to pipe");
	}
	if (pclose(fpin) == -1) err_sys("pclose error");
	putchar('\n');
	exit(0);
}
